package com.ostrich.shopping.room;

import com.ostrich.shopping.App;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

/**
 * @Author : yaotianxue
 * @Time : On 2023/9/27 10:50
 * @Description : AppDataBase
 */
@Database(entities = {User.class},version = 1,exportSchema = false)
public abstract class AppDataBase extends RoomDatabase {

    private static AppDataBase appDataBase;
    public static AppDataBase getInstance(){
        if(appDataBase == null){
            synchronized (AppDataBase.class){
                if(appDataBase == null){
                    appDataBase = Room.databaseBuilder(App.instance,AppDataBase.class,"shopping.db")
                            .allowMainThreadQueries()
                            .build();
                }
            }
        }
        return appDataBase;
    }

    public abstract UserDao getUserDao();

    private UserDao mUserDao;

}
